package com.yinhe.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yinhe.common.annotation.Log;
import com.yinhe.common.core.controller.BaseController;
import com.yinhe.common.core.domain.AjaxResult;
import com.yinhe.common.enums.BusinessType;
import com.yinhe.system.domain.YhSealMana;
import com.yinhe.system.service.IYhSealManaService;
import com.yinhe.common.utils.poi.ExcelUtil;
import com.yinhe.common.core.page.TableDataInfo;

/**
 * 印章管理Controller
 * 
 * @author yinhe
 * @date 2022-07-13
 */
@RestController
@RequestMapping("/system/mana")
public class YhSealManaController extends BaseController
{
    @Autowired
    private IYhSealManaService yhSealManaService;

    /**
     * 查询印章管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:mana:list')")
    @GetMapping("/list")
    public TableDataInfo list(YhSealMana yhSealMana)
    {
        startPage();
        List<YhSealMana> list = yhSealManaService.selectYhSealManaList(yhSealMana);
        return getDataTable(list);
    }

    /**
     * 导出印章管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:mana:export')")
    @Log(title = "印章管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YhSealMana yhSealMana)
    {
        List<YhSealMana> list = yhSealManaService.selectYhSealManaList(yhSealMana);
        ExcelUtil<YhSealMana> util = new ExcelUtil<YhSealMana>(YhSealMana.class);
        util.exportExcel(response, list, "印章管理数据");
    }

    /**
     * 获取印章管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:mana:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(yhSealManaService.selectYhSealManaById(id));
    }

    /**
     * 新增印章管理
     */
    @PreAuthorize("@ss.hasPermi('system:mana:add')")
    @Log(title = "印章管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YhSealMana yhSealMana)
    {
        return toAjax(yhSealManaService.insertYhSealMana(yhSealMana));
    }

    /**
     * 修改印章管理
     */
    @PreAuthorize("@ss.hasPermi('system:mana:edit')")
    @Log(title = "印章管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YhSealMana yhSealMana)
    {
        return toAjax(yhSealManaService.updateYhSealMana(yhSealMana));
    }

    /**
     * 删除印章管理
     */
    @PreAuthorize("@ss.hasPermi('system:mana:remove')")
    @Log(title = "印章管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(yhSealManaService.deleteYhSealManaByIds(ids));
    }
}
